<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>偶数行改变背景颜色</title>
    <style>
        table{
            border:1px solid orange;
            text-align:center;
        }
        td,th{
            border:1px solid orange;
        }
    </style>
    <script src="../../js/jquery-1.11.0.js"></script>
</head>
<body>
    <table cellpadding="3" cellspacing="0">
        <thead>
            <tr>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>学历</th>
                <th>职业</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>张小光</td>
                <td>男</td>
                <td>20</td>
                <td>本科</td>
                <td>学生</td>
            </tr>
            <tr>
                <td>张小光</td>
                <td>男</td>
                <td>20</td>
                <td>本科</td>
                <td>学生</td>
            </tr>
            <tr>
                <td>张小光</td>
                <td>男</td>
                <td>20</td>
                <td>本科</td>
                <td>学生</td>
            </tr>
            <tr>
                <td>张小光</td>
                <td>男</td>
                <td>20</td>
                <td>本科</td>
                <td>学生</td>
            </tr>
            <tr>
                <td>张小光</td>
                <td>男</td>
                <td>20</td>
                <td>本科</td>
                <td>学生</td>
            </tr>
        </tbody>
    </table>
</body>
<script>
    $("table tr").each(function(i,v){                       //遍历每行
        var nowTr = i+1;                                    //转化为行数
        if(nowTr%2==0){                                     //偶数行时
           v.style.backgroundColor="red";                   //原生js写法
           /*$(v).css("background","red");*/                //jQuery写法
        }
    });
</script>
</html>